/*
 *  SFClib - Secure File Container Library
 *
 *  util.h - Copyright(c) 2009 The SFCLib authors
 *
 *  The original author of this file is: Roberto Estrada Casarrubios.
 *
 *	This file is part of SFClib.
 *
 *  SFClib is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Lesser General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  SFClib is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public License
 *  along with SFClib.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef SFCUTILS_H
#define SFCUTILS_H

#include <openssl/aes.h>

/*
 * @fn	    int storeFile(FILE *file)
 * 
 * @brief	Writes the data of the file passed to the temporary data area
 *          compressed and encrypted.
 * 
 * @author	Roberto Estrada Casarrubios
 * 
 * @param	file The file whose content is to be written to the data area.
 * @param	encryptKey The AES encryption key to protect the data in the file.
 * 
 * @return	0 if succesful, -1 if any error occured.
 */
int storeFile(FILE *file, AES_KEY *encryptKey);

/*
 * @fn	int recoverFile(uint32 fd, FILE *dest, AES_KEY *decryptKey)
 * 
 * @brief	Recovers the file specified by the fd descriptor 
 * 
 * @author	Roberto Estrada Casarrubios
 * 
 * @param	fd		The file descriptor of the file to recover. 
 * @param	dest	A pointer to the location where the file will be extracted.
 * @param	decryptKey The AES decryption key to recover the data.
 * 
 * @return	0 if succesful, -1 if any error occured.
 */
int recoverFile(uint32 fd, FILE *dest, AES_KEY *decryptKey);

#endif